package date;

import org.apache.commons.lang3.StringUtils;
import org.junit.Test;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;

/**
 * @Author: ycy
 * @CreateDate: 2019/1/13 14:48
 */
public class CalendarDemo {

  public static void main(String[] args) {
    Calendar instance = Calendar.getInstance();
    instance.setTime(new Date());

    instance.set(Calendar.DAY_OF_MONTH, 10);
    System.out.println(instance.getTime().getTime());

    instance.set(Calendar.DAY_OF_MONTH, 11);
    instance.set(Calendar.HOUR_OF_DAY, 7);
    System.out.println(instance.getTime().getTime());

    instance.set(Calendar.HOUR_OF_DAY, 10);
    System.out.println(instance.getTime().getTime());
    instance.set(Calendar.HOUR_OF_DAY, 11);
    System.out.println(instance.getTime().getTime());
    instance.set(Calendar.HOUR_OF_DAY, 12);
    System.out.println(instance.getTime().getTime());

    instance.set(Calendar.DAY_OF_MONTH, 12);
    System.out.println(instance.getTime().getTime());
    //  1547362097000


    System.out.println(new Date());
    System.out.println(new Date(1546054455000L));


    int i = 3;
    System.out.println(i += 5);


    dafda(",546,564545,");

  }

  public static  void dafda(String topics) {

    if (StringUtils.isNotBlank(topics)) {
      StringBuilder sb = new StringBuilder();
      for (String s : topics.split(",")) {
        if (StringUtils.isNotBlank(s)) {
          sb.append(s).append(",");
        }
      }
      String sbString = sb.toString();
      if (sbString.endsWith(",")) {
        System.out.println(sbString.substring(0, sbString.length() - 1));
      }
    }

  }

  @Test
  public void testzone() {

    String STANDARD_DATE_FORMAT_UTC = "yyyyMMdd";
    SimpleDateFormat sdf = new SimpleDateFormat(STANDARD_DATE_FORMAT_UTC);
    System.out.println(sdf.format(new Date()));

  }

  //现在到今天结束的毫秒数c
  public Long getCurrent2TodayEndMillisTime() {
    Calendar todayEnd = Calendar.getInstance();
    // Calendar.HOUR 12小时制
    // HOUR_OF_DAY 24小时制
    todayEnd.set(Calendar.HOUR_OF_DAY, 23);
    todayEnd.set(Calendar.MINUTE, 59);
    todayEnd.set(Calendar.SECOND, 59);
    todayEnd.set(Calendar.MILLISECOND, 999);
    return todayEnd.getTimeInMillis()-new Date().getTime();
  }




}
